package com.demon.net

/**
 * 应用请求接口返回数据
 * <p/>
 * <p>
 * {"msg": {"code": 0,"info": ""},"data": true}
 * </p>
 *
 * @author zhaozeyang
 * @date 2020/8/25
 */
class AppResponse<T> : IAppResponse<T> {

  var data: T? = null
  var msg: String? = null
  var code: Int? = null


  companion object {
    const val CODE_SUCCESS = 0
  }

  override fun isSuccess(): Boolean = code == CODE_SUCCESS

  override fun isFailed(): Boolean = code != CODE_SUCCESS

  override fun isExpired(): Boolean {
    return false
  }

  override fun getResponseCode(): Int = code ?: 0

  override fun getResponseMessage(): String? = msg

  override fun getResponseData(): T? = data

}